﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Web.Script.Serialization;

namespace Liang.Device.Model.Camera
{
    /// <summary>
    /// 海康威视
    /// </summary>
    public class HikVision : CameraBase
    {
        /// <summary>
        /// 默认设备句柄（此句柄表示摄像头无效）
        /// </summary>
        public static readonly int DefaultDeviceHandle = -1;

        private int _LoginId = DefaultDeviceHandle;

        /// <summary>
        /// 设备句柄
        /// </summary>
        [ScriptIgnore]
        public int LoginId
        {
            get { return _LoginId; }
            set { _LoginId = value; }
        }
    }

    /// <summary>
    /// 海康IO报警抓拍数据
    /// </summary>
    [StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)]
    public struct HikIOAlarmCapture
    {
        /// <summary>
        /// 抓拍Id
        /// </summary>
        public int nCaptureId { get; set; }

        /// <summary>
        /// 摄像头登录id
        /// </summary>
        public int nLoginId { get; set; }

        /// <summary>
        /// 连拍序号
        /// </summary>
        public int PicNumber { get; set; }

        /// <summary>
        /// 车道号
        /// </summary>
        public int RoadNo { get; set; }

        /// <summary>
        /// 触发车道号
        /// </summary>
        public int DriveRoadNo { get; set; }

        /// <summary>
        /// 抓拍时间
        /// </summary>
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
        private string szCaptureTime;

        /// <summary>
        /// 获取抓拍时间
        /// </summary>
        /// <returns></returns>
        public DateTime GetCaptureTime()
        {
            return DateTime.Parse(szCaptureTime);
        }

        /// <summary>
        /// 图片文件
        /// </summary>
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
        private string szImageFile;

        /// <summary>
        /// 获取图片文件
        /// </summary>
        /// <returns></returns>
        public string GetImageFile()
        {
            return szImageFile;
        }

        /// <summary>
        /// 车牌号码
        /// </summary>
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)]
        private string szLicense;

        /// <summary>
        /// 获取车牌号码
        /// </summary>
        /// <returns></returns>
        public string GetPlate()
        {
            return szLicense;
        }

        /// <summary>
        /// 车牌颜色
        /// </summary>
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
        private string szPlateColor;

        /// <summary>
        /// 获取车牌颜色
        /// </summary>
        /// <returns></returns>
        public string GetPlateColor()
        {
            return szPlateColor;
        }
    }
}
